package com.hl.sfzy.service.wxwappService;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.entity.wxwapp.ArticleDetail;
import com.hl.sfzy.entity.wxwapp.TeacherDetail;
import com.hl.sfzy.mapper.wxwappMapper.ArticleDetailMapper;
import com.hl.sfzy.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @className: VueArticleService
 * @author: WXW
 * @date: 2024/9/9 10:05
 * @Version: 1.0
 * @description:
 */
@Service
public class VueArticleService {
    @Autowired
    private ArticleDetailMapper articleDetailMapper;
    public PageInfo<ArticleDetail> findAllArticle(Integer pageNum, Integer pageSize){
            PageHelper.startPage(pageNum, pageSize);
            List<ArticleDetail> articleDetails = articleDetailMapper.selectAllAryicle();
            PageInfo<ArticleDetail> pageInfo = new PageInfo<>(articleDetails);
            return pageInfo;
    }

    //查询教师id
    public List<TeacherDetail> findAllTeacherId(){
        return articleDetailMapper.selectTeacherId();
    }

    //新增文章
    public R addArticle(ArticleDetail articleDetail){
        int i = articleDetailMapper.insert(articleDetail);
        if (i > 0) {
            return R.success("添加成功");
        }else {
            return R.failure("添加失败");
        }
    }
}
